package com.xiang.producer;


import com.xiang.RabbitmqApplication;
import com.xiang.config.DirectConfig;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;

/**
 * 路由模式发送消息到交换机中
 *
 * @author: xiangtianlei
 * @Date: 2022-9-10
 */
@SpringBootTest(classes = RabbitmqApplication.class)
@RunWith(SpringRunner.class)
public class ProducerDirectTest {

    @Resource
    RabbitTemplate rabbitTemplate;

    @Test
    public void sendMsg() {
        rabbitTemplate.convertAndSend(DirectConfig.EXCHANGE_DIRECT, "Blue", "发送消息到key为Blue的队列中");
    }

    @Test
    public void sendMsg1() {
        rabbitTemplate.convertAndSend(DirectConfig.EXCHANGE_DIRECT, "Red", "发送消息到key为Red的队列中");
    }
}
